/**
 * Created by oneminute on 7/17/14.
 */

var lz = require("../lib/utils/modules")();

exports.post = function (_req, _res, _opts, _callback) {
    var issue = new lz.Issue(_req.body);
    if (!issue.content || issue.content.trim().length == 0) {
        _callback(lz.Config.errors.getError(lz.Config.errors.VALIDATE_PROPERTY_NOT_FOUND, {name: "content"}));
    } else {
        var user = _req.user;
        if (!user) {
            issue.uid = user.id;
        }
        issue.save(function (_err) {
            if (_err) {
                _callback(lz.Config.errors.getError(lz.Config.errors.ARANGODB_SYSTEM_ERROR));
            } else {
                _callback(null);
            }
        });
    }
};
